<div class="demo-content">
    <?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'model-_form-form',
    'enableAjaxValidation'=>false,
    'enableClientValidation'=>false,
    'clientOptions'=>array(  
        'validateOnSubmit'=>false,  
     ),
     'htmlOptions'=>array('class'=>'form-horizontal')
)); ?>
      <div class="control-group">
        <label class="control-label"><?php echo $this->_attributeLabels['model_name'] ?><span class="required">*</span>：</label>
        <div class="controls">
          <?php echo $form->textField($this->oModel,'model_name' ,array('data-rules'=>"{required:true}",'data-messages'=>"{required:'模型名称不能为空'}",'class'=>'input-normal ')); ?>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label"><?php echo $this->_attributeLabels['table_name'] ?><span class="required">*</span>：</label>
        <div class="controls">
          <?php
          $aHtmlOption = array('data-rules'=>"{required : true ,regexp:/^[A-Za-z.\_]+$/}",'data-messages'=>"{regexp:'表名必须为英文字符' ,required:'表不能为空'}",'data-tip'=>"{text:'请输入模型名称'}",'class'=>'input-normal');
          if(isset($this->oModel->table_name) &&  $this->oModel->table_name){
               $aHtmlOption = array('data-rules'=>"{required : true ,regexp:/^[A-Za-z.\_]+$/}",'data-messages'=>"{regexp:'表名必须为英文字符' ,required:'表不能为空'}",'data-tip'=>"{text:'请输入模型名称'}",'class'=>'input-normal' ,'readonly'=>'true'); 
          }
          echo $form->textField($this->oModel,'table_name' ,$aHtmlOption); ?>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label"><?php echo $this->_attributeLabels['description'] ?>：</label>
        <div class="controls">
          <?php echo $form->textField($this->oModel,'description',array('data-rules'=>"{maxlength:100}",'data-messages'=>"{maxlength:'描述不能超过100字'}",'class'=>'input-large')); ?>
                
        </div>
      </div>
      <div class="control-group">
        <label class="control-label"><?php echo $this->_attributeLabels['default_style'] ?><span class="required">*</span>：</label>
        <div class="controls">
          <?php echo $form->dropdownlist($this->oModel,'default_style',$aTemplateList ,array('class'=>'input-normal selectTemplate' ,'separator'=>'&nbsp;')); ?>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label"><?php echo $this->_attributeLabels['category_template'] ?><span class="required">*</span>：</label>
        <div class="controls categoryTemplate">
          <?php echo $form->dropdownlist($this->oModel,'category_template',$aTemplate['category'] ,array('class'=>'input-normal' ,'separator'=>'&nbsp;')); ?>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label"><?php echo $this->_attributeLabels['list_template'] ?><span class="required">*</span>：</label>
        <div class="controls listTemplate">
          <?php echo $form->dropdownlist($this->oModel,'list_template',$aTemplate['list'] ,array('class'=>'input-normal' ,'separator'=>'&nbsp;')); ?>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label"><?php echo $this->_attributeLabels['show_template'] ?><span class="required">*</span>：</label>
        <div class="controls showTemplate">
          <?php echo $form->dropdownlist($this->oModel,'show_template',$aTemplate['show'] ,array('class'=>'input-normal' ,'separator'=>'&nbsp;')); ?>
        </div>
      </div>   
    <?php $this->endWidget(); ?>
<!-- script end -->
</div>
<script type="text/javascript">
//切换模板
$('.selectTemplate').bind('change' ,function(){
    //获取对应模板
    var jqThis = $(this) , sTemplate = jqThis.val() ,url='<?php echo $this->createUrl('model/ajaxTemplateList') ?>'+'?sTemplate='+sTemplate;
    $.getJSON(url ,function(jData){
        if( jData.err==0 ){
            $('.categoryTemplate').html(jData.data.category);
            $('.listTemplate').html(jData.data.list);
            $('.showTemplate').html(jData.data.show);
        }
    });
});
</script>